﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Migrator.Util
{
    /// <summary>
    /// Extensions methods for the PointF class
    /// </summary>
    public static class PointFExtensions
    {
        /// <summary>
        /// Calculates the distance bewteen two points
        /// </summary>
        /// <param name="point">Point A</param>
        /// <param name="other">Point B</param>
        /// <returns>The distance between the points</returns>
        public static double DistanceTo(this PointF point, PointF other)
        {
            return Math.Sqrt(Math.Pow(point.X - other.X, 2) + Math.Pow(point.Y - other.Y, 2));
        }

        /// <summary>
        /// Displaces the point's position by dx in the X axis and dy in the Y axis
        /// </summary>
        /// <param name="point">The point to displace</param>
        /// <param name="dx">X axis displacement</param>
        /// <param name="dy">Y axis displacement</param>
        /// <returns>The new, displaced, point.</returns>
        public static PointF DisplaceBy(this PointF point, float dx, float dy)
        {
            return new PointF(point.X + dx, point.Y + dy);
        }
    }
}
